package com.exsun.ex1077.network.entity

import com.exsun.ex1077.app.Constant
import com.exsun.ex1077.model.LatLng
import com.zhangping.amap.extend.getCenterPoint
import java.io.Serializable

//{
//    "id": "1060222147114438656",
//    "companyId": "1002522941075886080",
//    "companyName": "车辆",
//    "name": "1545",
//    "type": 2,
//    "geoxy": {
//    "aoLatLng": [
//    {
//        "lng": 114.50500488281251,
//        "lat": 30.691474747748764
//    },
//    {
//        "lng": 114.52423095703126,
//        "lat": 30.627683379760217
//    },
//    {
//        "lng": 114.38278198242188,
//        "lat": 30.643044408414394
//    },
//    {
//        "lng": 114.39102172851564,
//        "lat": 30.68438889745345
//    }
//    ]
//},
//    "geoxyStr": "",
//    "mapxy": {
//    "aoLatLng": [
//    {
//        "lng": 114.51028854155312,
//        "lat": 30.68904284144286
//    },
//    {
//        "lng": 114.52943841358898,
//        "lat": 30.625167077473535
//    },
//    {
//        "lng": 114.38833356125122,
//        "lat": 30.64078123244373
//    },
//    {
//        "lng": 114.3965789728967,
//        "lat": 30.682149670208357
//    }
//    ]
//},
//    "mapxyStr": "",
//    "radius": "",
//    "address": "湖北省武汉市洪山区公厕",
//    "alarmRuleId": "",
//    "bindStatus": "",
//    "bindStatusName": "",
//    "gmtCreate": "2023-01-04 15:44:18",
//    "createUserId": "62",
//    "createUserName": "田影1",
//    "gmtModified": "",
//    "modifiedUserId": "",
//    "companyShortName": "车辆"
//}

data class Bounds(
    val address: String = "",
    val alarmRuleId: String? = null,
    val bindStatus: String? = null,
    val bindStatusName: String? = null,
    val companyId: String = "",
    val companyName: String = "",
    val companyShortName: String? = null,
    val createUserId: String? = null,
    val createUserName: String = "",
    val geoxy: GeoXY? = null,
    val geoxyStr: String? = null,
    val gmtCreate: String = "",
    val gmtModified: String? = null,
    val id: String = "",
    val mapxy: GeoXY? = null,
    val mapxyStr: String? = null,
    val modifiedUserId: String? = null,
    var name: String = "",
    val radius: String? = null,
    val type: Int = Constant.BOUNDS_TYPE_POLYGON
): Serializable{

    class GeoXY: Serializable{
        val aoLatLng: List<LatLng>? = null
    }

    fun personFormat() = "创建人：${createUserName}"

    fun companyNameFormat() = "所属公司：${companyName}"

    fun getBoundsLatLngList() = mapxy?.aoLatLng?.map { com.amap.api.maps.model.LatLng(it.lat, it.lng) } ?: emptyList()

    fun getCenterLatLng() = getCenterPoint(getBoundsLatLngList())
}